package br.unifor.mia.olio;

import java.io.Serializable;
import java.lang.Boolean;
import java.lang.Long;
import java.lang.String;
import java.util.Calendar;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: Execution
 * 
 */
@Entity(name = "Execution")
@Table(name = "EXE_EXECUTION")
@NamedQueries(value = {
		@NamedQuery(name = "findAll", query = "select OBJECT(o) from Execution o order by o.instanceType.id, o.users, o.when"),
		@NamedQuery(name = "findByIds", query = "select OBJECT(o) from Execution o where o.id in (:ids) order by o.instanceType.id, o.users, o.when"),
		@NamedQuery(name = "findByFields", query = "select OBJECT(o) from Execution o where (:dataInicial is null or o.when >= :dataInicial) and (:dataFinal is null or o.when >= :dataFinal) and (:users is null or o.users in (:users)) order by o.instanceType.id, o.users, o.when") })
public class Execution implements Serializable {

	private static final long serialVersionUID = 1L;

	@Column(name = "exe_id", nullable = false, unique = true)
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(name = "exe_name", nullable = false, unique = true)
	private String name;

	@Column(name = "exe_description", nullable = false, unique = false)
	private String description;

	@Column(name = "exe_success", nullable = false, unique = false)
	private Boolean success;

	@Column(name = "exe_when", nullable = false, unique = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar when;

	@Column(name = "exe_users", nullable = false, unique = false)
	private Integer users;
	
	
	@ManyToOne(optional=false,fetch=FetchType.EAGER) 
    @JoinColumn(name="exe_IST_id",referencedColumnName="IST_id", nullable=false, updatable=false)
	private InstanceType instanceType;

	public Execution() {
		super();
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Boolean getSuccess() {
		return this.success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public Calendar getWhen() {
		return this.when;
	}

	public void setWhen(Calendar when) {
		this.when = when;
	}

	public void setUsers(Integer users) {
		this.users = users;
	}

	public Integer getUsers() {
		return users;
	}

	public void setInstanceType(InstanceType instanceType) {
		this.instanceType = instanceType;
	}

	public InstanceType getInstanceType() {
		return instanceType;
	}

}
